package com.coocaa.ops.admin.v1.globalparams.biz;

import com.coocaa.ops.admin.v1.globalparams.mapper.IGlobalParamsContentMapper;
import com.coocaa.ops.common.core.base.BaseBizImpl;
import com.coocaa.ops.common.core.base.mybatis.UpdateTemplate;
import com.coocaa.ops.common.core.biz.globalparams.entity.GlobalParamsContentEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : hql
 * @date : 2020/7/16 11:08
 * @description
 */
@Service
public class GlobalParamsContentBizImpl extends BaseBizImpl<IGlobalParamsContentMapper, GlobalParamsContentEntity> implements IGlobalParamsContentBiz {

    @Override
    public void saveBatchContents(List<GlobalParamsContentEntity> contentList) {
        if (CollectionUtils.isNotEmpty(contentList)) {
            insertBatch(contentList);
        }
    }

    @Override
    public void deleteRlsContent(Integer id) {
        UpdateTemplate<GlobalParamsContentEntity> update = UpdateTemplate.getUpdateTemplate();
        update.eq("global_params_id", id);
        if (getMapper().selectCount(update) > 0) {
            //逻辑删除
            GlobalParamsContentEntity delete = new GlobalParamsContentEntity();
            delete.setFlag(0);
            getMapper().update(delete, update);
        }
    }
}
